#####################################
## "Backyard politics in Foreign Aid"
## William Christiansen
## Tobias Heinrich
## Timothy Peterson
#####################################

## Files that executes the script for the
## preregistration

rm(list=ls())
set.seed(12012016)
## Set working directory
##########################
 setwd("/Users/th5/Dropbox/Projects/NIMBY/experiment/preregistration/Dataverse")
#setwd("/Users/tobiasheinrich/Dropbox/Projects/NIMBY/preregistration/analysis")
 #setwd("/Users/timothypeterson/documents/Dropbox/NIMBY/preregistration/analysis")
dir.create(path="output", showWarnings = FALSE)


## There's some incompability issue in the most current (12/1/2016) ggplot version
## with ggmap. This is for descriptives. 
library(devtools)
install_version("ggplot2", version = "2.1.0", repos = "http://cran.us.r-project.org")


## Load packages, scripts
#########################
library(foreign)
library(matrixStats)
library(plyr)
library(geosphere)
library(randomForest)
library(stringr)
library(stargazer)
library(zipcode)
data(zipcode)
library(scales)
library(RItools)
#library(MBESS)
library(ggmap)
library(reshape2)
library(rms)
source("Rx_Auxiliary functions.R")


## 1) Generate files used in the survey experiment
source("R1_Make website files.R")

## 2) Prepare data from the MTurk output
source("R2_Prep MTurk data.R")

## 3) Check balance
source("R3_Balance and descriptives.R")

## 4) Estimation of models
## Set number of bootstrap draws
n_bs <- 5000
source("R4_Estimate models.R")

## 5) Main graph
source("R5_Make main graph.R")

## 6) Regression tables
source("R6_Regression tables.R")






